<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Xenon Boostrap Admin Panel" />
    <meta name="author" content="" />

    <title>校园e商</title>

*{<link rel="stylesheet" href="http://fonts.useso.com/css?family=Arimo:400,700,400italic">}*
    <link rel="stylesheet" href="/public/css/fonts/linecons/css/linecons.css">
    <link rel="stylesheet" href="/public/css/fonts/fontawesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/public/css/bootstrap.css">
    <link rel="stylesheet" href="/public/css/xenon-core.css">
    <link rel="stylesheet" href="/public/css/xenon-forms.css">
    <link rel="stylesheet" href="/public/css/xenon-components.css">
    <link rel="stylesheet" href="/public/css/xenon-skins.css">
    <link rel="stylesheet" href="/public/css/custom.css">

    <script src="/public/js/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="/public/jquery/jquery.qrcode.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script type="text/javascript" src="/public/pingxx/pingpp-pc.js"></script>
    <script src="/public/js/toastr/toastr.min.js"></script>


</head>
<body style="background: #ffffff;padding: 20px 20px;">
<div style="width: 250px; height: 250px;margin: 30px auto;display: none;" id="wechat-img" ></div>
<div id="creadit" style="display: none;">
    <table cellpadding="0" cellspacing="0" align="center" style="margin: 30px 0px;margin-left: 25px;">
        <tr>
            <td width="100px">订单编号:</td>
            <td height="45px">
                <input type="text" class="form-control" readonly value="${order?.orderNumber}" style="width:300px;">
            </td>
        </tr>
        <tr>
            <td>订单金额(元):</td>
            <td height="45px">
                <input type="text" class="form-control" readonly value="${order?.amount}" style="width:300px;">
            </td>
        </tr>
        <tr>
            <td>手机号:</td>
            <td height="45px">
                <input type="text" class="form-control" id="phone" style="width:300px;">
            </td>
        </tr>
    </table>
</div>
<div id="other" style="text-align: center;display: none;">
    <button class="btn btn-turquoise btn-lg" id="bespeak_btn">确认</button>
</div>
<!-- Bottom Scripts -->
<script src="/public/js/bootstrap.min.js"></script>
<script src="/public/js/TweenMax.min.js"></script>
<script src="/public/js/resizeable.js"></script>
<script src="/public/js/joinable.js"></script>
<script src="/public/js/xenon-api.js"></script>
<script src="/public/js/xenon-toggles.js"></script>


<!-- Imported scripts on this page -->
<script src="/public/js/xenon-widgets.js"></script>
<script src="/public/js/devexpress-web-14.1/js/globalize.min.js"></script>
<script src="/public/js/devexpress-web-14.1/js/dx.chartjs.js"></script>


<!-- JavaScripts initializations and stuff -->
<script src="/public/js/xenon-custom.js"></script>

<script type="text/javascript" src="/public/lib/layer/js/layer.js"></script>

<script>

    $(function(){
        var payType = '';
        var orderNumber = '${orderNumber}';
        var thisval = "${payType}";
        //alert("选中的数字:" + thisval);
        if(thisval == "1") {// 微信
            $("#creadit").hide();
            payType = 'wx_pub_qr';
            getCode(payType, orderNumber);
        }else if(thisval == "2") {// 支付宝
            //$("#creadit").hide();
            //layer.alert("切换飞科正式环境后启用!");
            $('#wechat-img').hide();
            $("#other").show();
            $("#default").hide();
            $("#creadit").show();
            $("#bespeak_btn").unbind("click").bind("click", function(){
                if($("#phone").val() == ""){
                    layer.msg('请输入手机号');
                    $("#phone").focus()
                    return;
                }
                payType = 'alipay_qr';
                getCode(payType, orderNumber);
//                $.getJSON("/admin/order/aliFirst/"+orderNumber+"/"+$("#phone").val(), null,
//                    function (data) {
//                        if(!data.success){
//                            layer.msg(data.msg);
//                            return;
//                        }
//                        window.parent.aliRedirect();
//                    }
//                );
            });
        } else if(thisval == "21") {// 支付宝
            $("#creadit").hide();
//            layer.alert("切换飞科正式环境后启用!");
                payType = 'alipay_qr';
                getCode(payType, orderNumber);
        } else if(thisval == "3") {// 会员卡
            $('#wechat-img').hide();
            $("#other").show();
            $("#default").hide();
            $("#creadit").show();

            $("#bespeak_btn").unbind("click").bind("click", function(){
                if($("#phone").val() == ""){
                    layer.msg('请输入手机号');
                    $("#phone").focus()
                    return;
                }
                $.getJSON("/BS0017/admin/order/cashpay",{orderNumber: orderNumber, phone: $("#phone").val()},
                    function (data) {
                        layer.alert(data.msg);
                    }
                );
            });
        }else if(thisval == "4") {// 现金
            $('#wechat-img').hide();
            $("#other").show();
            $("#default").hide();
            $("#creadit").show();
            $("#bespeak_btn").unbind("click").bind("click", function(){
                $.getJSON("/api/payments/cash",{orderNumber: orderNumber , phone: $("#phone").val()},
                    function (data) {
                        if(data.success) {
                            window.parent.location.reload();
                        } else {
                            layer.alert(data.msg);
                        }
                    }
                );
            });
        }else if(thisval == "5") {// 银行卡
            $('#wechat-img').hide();
            $("#other").show();
            $("#default").hide();
            $("#creadit").show();
            $("#bespeak_btn").unbind("click").bind("click", function(){
                $.getJSON("/api/payments/cash",{orderNumber: orderNumber, phone: $("#phone").val()},
                    function (data) {
                        if(data.success) {
                            window.parent.location.reload();
                        } else {
                            layer.alert(data.msg);
                        }
                    }
                );
            });
        }else if(thisval == "6") {// 信用卡
            $('#wechat-img').hide();
            $("#other").show();
            $("#default").hide();
            $("#creadit").show();
            $("#bespeak_btn").unbind("click").bind("click", function(){
                $.getJSON("/api/payments/cash",{orderNumber: orderNumber, phone: $("#phone").val()},
                    function (data) {
                        if(data.success) {
                            window.parent.location.reload();
                        } else {
                            layer.alert(data.msg);
                        }
                    }
                );
            });
        }
    })

    function getCode(payType, orderNumber){
        //alert("getCode : " + payType + " orderNumber :" + orderNumber);
        $.getJSON("/api/payments/chargeWeiXinQrJson",{orderNumber: orderNumber, payType : payType },
            function (data) {
                if(data.success) {
                    $('#wechat-img').qrcode({width:250,height:250,correctLevel:0,text: data.qrcode}).show();
//                    $('#wechat-img').qrcode(data.qrcode); //任意字符串
                    $("#other").show();
                    $("#default").hide();
                    $("#creadit").hide();

                    $("#bespeak_btn").unbind("click").bind("click", function(){
                        window.parent.location.reload();
                    });
                } else {
                    layer.alert(data.msg);
                }
            }
        );
    }

</script>
</body>
</html>